package com.tsinghua.discharge.controller;

import com.github.pagehelper.PageInfo;
import com.tsinghua.discharge.common.Const;
import com.tsinghua.discharge.common.ServerResponse;
import com.tsinghua.discharge.model.User;
import com.tsinghua.discharge.model.BaseData;
import com.tsinghua.discharge.service.CalALParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/CalculateALparam")

public class CalALParamController {
    @Autowired
    CalALParamService calALParamService;
    @RequestMapping(value = "/CalculateAL.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse calAlParameter(HttpSession session){

        return calALParamService.calALParameter(session);
    }


    @RequestMapping(value = "/SelectAL.do",method = RequestMethod.GET)
    @ResponseBody
    public ServerResponse<PageInfo> selectCalculateAL(@RequestParam(value = "page",defaultValue = "1") Integer page, @RequestParam(value = "limit",defaultValue = "10")Integer limit,@RequestParam(value = "scenario") String scenario,@RequestParam(value = "date") String date,@RequestParam(value = "fuel") String fuel,@RequestParam(value = "region") String region, @RequestParam(value = "superSector")String superSector,@RequestParam(value = "sector") String sector,@RequestParam(value = "service") String service, @RequestParam(value = "technology")String technology,HttpSession session){

        return calALParamService.selectAL(page,limit,scenario,date,fuel,region,superSector,sector,service,technology,session);
    }


    @RequestMapping(value = "/SumBySector.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse CalculateSum(HttpSession session, String Sector,String date, String scenario,String fuel,String region){

        return calALParamService.CalculateSum( session,  Sector, date,  scenario, fuel, region);
    }

    @RequestMapping(value = "/ALSumByRegion.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse ALSumByRegion(HttpSession session,String scenario,String date,String fuel,String superSector,String sector,String service,String technology){

        return calALParamService.ALSumByRegion(session,scenario,date,fuel,superSector,sector,service,technology);
    }


    @RequestMapping(value = "/SumByTime.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse SumByTime(String scenario, String start_year, String end_year,String fuel,
                                    String region, String superSector, String sector,
                                    String service, String technology, HttpSession session){

        return calALParamService.SumByTime(scenario, start_year,end_year,fuel,
                region, superSector, sector,
                service, technology,session);
    }



}
